import requests
import json

url = "http://69.231.135.101/pgktstudent/studentCourseHomework/queryCourseTree"
headers = {
    "Accept": "application/json, text/plain, */*",
    "Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
    "Authorization": "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImM5NDNmOGQwLWEwY2MtNDRkNi05Y2E4LWQzODM0ODk4M2YwYSJ9.mOpszL8HEPHnz7hMIiNR04AaL7EJCdVwV3VkHbKgXNsmgUjJ0-DIZ4WmDkoHl6FoPWXCuuJUDN4UmvtsNcShAw",
    "Connection": "keep-alive",
    "Content-Type": "application/json",
    "Origin": "http://69.231.135.101",
    "Referer": "http://69.231.135.101/pgktjwsnew/",
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0"
}

# 空的json数据
data = {}

response = requests.post(url, headers=headers, json=data, verify=False)

try:
    json_data = response.json()
    # 只保存 "data" 字段内容
    only_data = json_data.get("data", [])
    with open('course_tree_data.json', 'w', encoding='utf-8') as f:
        json.dump(only_data, f, ensure_ascii=False, indent=4)
    print("已成功保存 'data' 字段到 course_tree_data.json")
except Exception as e:
    print("获取或解析数据失败:", e)